package rfc3962import ()const ( s2kParamsZero = 4294967296)// StringToKey returns a key derived from the string provided according to the definition in RFC 3961.func (, , string, etype.EType) ([]byte, error) { , := S2KparamsToItertions()if != nil {returnnil, }returnStringToKeyIter(, , , )}// StringToPBKDF2 generates an encryption key from a pass phrase and salt string using the PBKDF2 function from PKCS #5 v2.0func (, string, int64, etype.EType) []byte {returnpbkdf2.Key64([]byte(), []byte(), , int64(.GetKeyByteSize()), .GetHashFunc())}// StringToKeyIter returns a key derived from the string provided according to the definition in RFC 3961.func (, string, int64, etype.EType) ([]byte, error) { := .RandomToKey(StringToPBKDF2(, , , ))return .DeriveKey(, []byte("kerberos"))}// S2KparamsToItertions converts the string representation of iterations to an integerfunc ( string) (int64, error) {//The s2kparams string should be hex string representing 4 bytes //The 4 bytes represent a number in big endian order //If the value is zero then the number of iterations should be 4,294,967,296 (2^32)varuint32iflen() != 8 {returnint64(s2kParamsZero), errors.New("invalid s2kparams length") } , := hex.DecodeString()if != nil {returnint64(s2kParamsZero), errors.New("invalid s2kparams, cannot decode string to bytes") } = binary.BigEndian.Uint32()returnint64(), nil}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.